package day10.ZiXi.HashMap集合应用案例;

import java.util.HashMap;
import java.util.Set;

public class HashMapDemo {
    public static void main(String[] args) {
        //创建HashMap集合对象
        HashMap<Student,String > hm = new HashMap<>();
        //创建学生对象
        Student s1 = new Student("林青霞",30);
        Student s2 = new Student("张曼玉",35);
        Student s3 = new Student("王祖贤",33);
        Student s4 = new Student("王祖贤",33);

        //把学生添加到集合
        hm.put(s1,"西安");
        hm.put(s2,"武汉");
        hm.put(s3,"郑州");
        hm.put(s4,"西北京");
        ////遍历集合
        Set<Student> students = hm.keySet();
        for (Student student : students) {
            String ss = hm.get(student);
            System.out.println(student.getName()+","+student.getAge()+","+ss);

        }
    }
}
